#include "subwindow.h"
#include "ui_subwindow.h"
#include <QStyle>
#include <QDebug>
#include <QWindow>

SubWindow::SubWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::SubWindow)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint  | Qt::WindowStaysOnTopHint); // | Qt::WindowStaysOnBottomHint);
//    setWindowState(Qt::WindowFullScreen);
    qDebug() << "SubWindow wid: " << this->window()->winId();
}

SubWindow::~SubWindow()
{
    delete ui;
}

void SubWindow::updateBackgroundStyle_step(bool islocal, bool todark, quint32 step)
{
    Q_UNUSED(todark);
    ui->centralwidget->setProperty("systemstyle", islocal ? "local" : "cloud");

    switch (step){
    case 0:
        ui->centralwidget->setProperty("lightstyle", misLocal ? "local_to_dark1" : "cloud_to_dark1");
        break;
    case 1:
        ui->centralwidget->setProperty("lightstyle", misLocal ? "local_to_dark2" : "cloud_to_dark2");
        break;
    case 2:
        ui->centralwidget->setProperty("lightstyle", misLocal ? "local_to_dark3" : "cloud_to_dark3");
        break;
    case 3:
        ui->centralwidget->setProperty("lightstyle", misLocal ? "local_to_dark4" : "cloud_to_dark4");
        break;
    case 4:
        ui->centralwidget->setProperty("lightstyle", misLocal ? "local_to_dark5" : "cloud_to_dark5");
        break;
    case 5:
        ui->centralwidget->setProperty("lightstyle", misLocal ? "local_to_dark6" : "cloud_to_dark6");
        break;
    default:
        break;
    }

    ui->centralwidget->style()->polish(ui->centralwidget);
    update();
}

void SubWindow::updateBackgroundStyle(bool isLocal, bool isDark)
{
    misLocal = isLocal;
    ui->centralwidget->setProperty("lightstyle", isDark ? "dark" : "light");
    ui->centralwidget->setProperty("systemstyle", isLocal ? "local" : "cloud");
    ui->centralwidget->style()->polish(ui->centralwidget);
    update();
}
